<!DOCTYPE html>
<html>
  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <meta name="viewport" content="width=device-width,initial-scale=1,user-scalable=0,minimum-scale=1.0,maximum-scale=1.0" />
    <meta name="author" content="火星科技 http://mars3d.cn " />
    <meta name="apple-touch-fullscreen" content="yes" />
    <meta name="apple-mobile-web-app-capable" content="yes" />
    <meta name="apple-mobile-web-app-status-bar-style" content="black" />
    <meta name="format-detection" content="telephone=no" />
    <meta name="x5-fullscreen" content="true" />
    <meta http-equiv="X-UA-Compatible" content="IE=Edge,chrome=1" />
    <!-- 标题及搜索关键字 -->
    <meta name="keywords" content="火星科技,cesium,3D,GIS,marsgis,三维,地球,地图,开发,框架,系统,示例,资料,模型,离线,外包,合肥,安徽,中国" />
    <meta
      name="description"
      content="火星科技 合肥火星 合肥火星科技 合肥火星科技有限公司 leaflet leaflet框架 leaflet开发 cesium cesium开发 cesium框架 三维 地球 模型  gis marsgis 地图离线 地图开发 地图框架 地图外包 框架 开发 外包  地图离线 二维地图 三维地图 全景漫游 地理信息系统 云GIS 三维GIS GIS平台 WebGIS"
    />

    <link rel="shortcut icon" type="image/x-icon" href="http://mars3d.cn/favicon.ico" />
    <title>功能示例 | Mars3D | 三维地图 | 火星科技 | 合肥火星科技有限公司</title>

    <!--第三方lib-->
    <script
      type="text/javascript"
      src="../lib/include-lib.js"
      libpath="../lib/"
      include="jquery,font-awesome,bootstrap,layer,haoutil,mars3d"
    ></script>

    <link href="css/style.css" rel="stylesheet" />

    <style>
      @font-face {
        font-family: "UnidreamLED";
        src: url("./css/fonts/UnidreamLED.ttf") format("truetype");
      }

      .coneNum {
        font-family: "UnidreamLED";
        font-size: 26px;
        color: #febc01;
        background: linear-gradient(180deg, #fecb01 0%, #fe4201 100%);
        white-space: nowrap;
        -webkit-background-clip: text;
        -webkit-text-fill-color: transparent;
      }
    </style>
  </head>

  <body class="dark">
    <!--加载前进行操作提示，优化用户体验-->
    <div id="mask" class="signmask" onclick="removeMask()"></div>

    <div id="mars3dContainer" class="mars3d-container"></div>

    <script src="./js/common.js"></script>
    <script type="text/javascript">
      "use script"; //开发环境建议开启严格模式

      var map;

      function initMap(options) {
        //合并属性参数，可覆盖config.json中的对应配置

        var mapOptions = mars3d.Util.merge(options, {
          scene: {
            center: { lat: 30.053342, lng: 117.677104, alt: 187118, heading: 350, pitch: -50 },
            showSun: false,
            showMoon: false,
            showSkyBox: false,
            showSkyAtmosphere: false,
            fog: false,
            backgroundColor: " #120f44", //天空背景色
            globe: {
              baseColor: "#120f44", //地球地面背景色
              showGroundAtmosphere: false,
              enableLighting: false,
            },
          },
          control: {
            baseLayerPicker: false,
          },
          basemaps: [],
          layers: [],
        });
        //创建三维地球场景
        map = new mars3d.Map("mars3dContainer", mapOptions);

        // 合肥市边界墙
        var borderWall = new mars3d.layer.GeoJsonLayer({
          name: "合肥市边界墙",
          url: "//data.mars3d.cn/file/geojson/areas/340100.json",
          symbol: {
            type: "wallP",
            styleOptions: {
              setHeight: -25000,
              diffHeight: 25000, //墙高
              materialType: mars3d.MaterialType.Image2,
              image: "./img/textures/grawall.png",
              color: "#4881A7",
            },
          },
        });
        map.addLayer(borderWall);

        //创建矢量数据图层
        var graphicLayer = new mars3d.layer.GraphicLayer();
        map.addLayer(graphicLayer);

        queryAreasData().then(function (geojson) {
          let arr = mars3d.Util.geoJsonToGraphics(geojson); //解析geojson

          for (let i = 0; i < arr.length; i++) {
            let item = arr[i];

            //polygon面
            var polygonEntity = new mars3d.graphic.PolygonEntity({
              positions: item.positions,
              style: {
                fill: true,
                color: "#4881a7",
                opacity: 0.5,
                label: {
                  text: item.attr.name,
                  font_size: 20,
                  color: "#ffffff",
                  font_family: "楷体",
                  outline: true,
                  outlineColor: "black",
                  setHeight: 2000,
                  visibleDepth: false,
                  distanceDisplayCondition: new Cesium.DistanceDisplayCondition(0.0, 500000),
                  scaleByDistance: new Cesium.NearFarScalar(200000, 1.0, 500000, 0.5),
                },
              },
            });
            graphicLayer.addGraphic(polygonEntity);

            //PolylineEntity线
            var graphicLine = new mars3d.graphic.PolylineEntity({
              positions: item.positions,
              style: {
                color: "rgba(255,255,255,0.5)",
                width: 1,
              },
            });
            graphicLayer.addGraphic(graphicLine);

            //中心点
            var center = item.attr.centroid;

            //光锥体
            var coneGlow = new mars3d.graphic.LightCone({
              position: center,
              style: {
                radius: 1500,
                height: 15000,
              },
            });
            graphicLayer.addGraphic(coneGlow);

            //LED数字显示
            var number = Math.floor(Math.random() * (4000 - 3000 + 1) + 3000); //随机数字 3000-4000
            var graphic = new mars3d.graphic.DivGraphic({
              position: [center[0], center[1], 12000],
              style: {
                html: `<div class ="coneNum">${number}`,
                horizontalOrigin: Cesium.HorizontalOrigin.CENTER,
                verticalOrigin: Cesium.VerticalOrigin.CENTER,
                distanceDisplayCondition: new Cesium.DistanceDisplayCondition(0.0, 500000),
                scaleByDistance: new Cesium.NearFarScalar(200000, 1.0, 500000, 0.5),
              },
            });
            graphicLayer.addGraphic(graphic);
          }
        });
      }

      function queryAreasData() {
        return new Promise(function (resolve, reject) {
          $.ajax({
            url: "//data.mars3d.cn/file/geojson/areas/340100_full.json",
            type: "get",
            dataType: "json",
            success: function (geojson) {
              resolve(geojson);
            },
            error: function (data) {
              reject(data);
            },
          });
        });
      }
    </script>
  </body>
</html>
